home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / tables / table.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  7.0 KB  |  197 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00FFFF00&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "MarkUps R Us"
  6.    ClientHeight    =   2880
  7.    ClientLeft      =   1605
  8.    ClientTop       =   1740
  9.    ClientWidth     =   6225
  10.    Height          =   3285
  11.    Left            =   1545
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   2880
  17.    ScaleWidth      =   6225
  18.    Top             =   1395
  19.    Width           =   6345
  20.    Begin VScrollBar VScroll1 
  21.       Height          =   2055
  22.       Left            =   5640
  23.       TabIndex        =   4
  24.       Top             =   480
  25.       Width           =   255
  26.    End
  27.    Begin Label Label5 
  28.       Alignment       =   1  'Right Justify
  29.       BorderStyle     =   1  'Fixed Single
  30.       Caption         =   "InStock"
  31.       Height          =   2055
  32.       Left            =   4680
  33.       TabIndex        =   10
  34.       Top             =   480
  35.       Width           =   975
  36.    End
  37.    Begin Label Label4 
  38.       Alignment       =   1  'Right Justify
  39.       BackColor       =   &H00FFFFFF&
  40.       BorderStyle     =   1  'Fixed Single
  41.       Caption         =   "Price"
  42.       ForeColor       =   &H00FF0000&
  43.       Height          =   2055
  44.       Left            =   3720
  45.       TabIndex        =   3
  46.       Top             =   480
  47.       Width           =   975
  48.    End
  49.    Begin Label Label3 
  50.       Alignment       =   1  'Right Justify
  51.       BorderStyle     =   1  'Fixed Single
  52.       Caption         =   "MarkUp"
  53.       Height          =   2055
  54.       Left            =   2760
  55.       TabIndex        =   2
  56.       Top             =   480
  57.       Width           =   975
  58.    End
  59.    Begin Label Label2 
  60.       Alignment       =   1  'Right Justify
  61.       BorderStyle     =   1  'Fixed Single
  62.       Caption         =   "Cost"
  63.       Height          =   2055
  64.       Left            =   1800
  65.       TabIndex        =   1
  66.       Top             =   480
  67.       Width           =   975
  68.    End
  69.    Begin Label Label1 
  70.       BorderStyle     =   1  'Fixed Single
  71.       Caption         =   "ProdName"
  72.       Height          =   2055
  73.       Left            =   360
  74.       TabIndex        =   0
  75.       Top             =   480
  76.       Width           =   1455
  77.    End
  78.    Begin Label Label10 
  79.       Alignment       =   2  'Center
  80.       BackColor       =   &H00C0C0C0&
  81.       BorderStyle     =   1  'Fixed Single
  82.       Caption         =   "In Stock"
  83.       Height          =   255
  84.       Left            =   4680
  85.       TabIndex        =   9
  86.       Top             =   240
  87.       Width           =   975
  88.    End
  89.    Begin Label Label9 
  90.       Alignment       =   2  'Center
  91.       BackColor       =   &H00C0C0C0&
  92.       BorderStyle     =   1  'Fixed Single
  93.       Caption         =   "Price"
  94.       Height          =   255
  95.       Left            =   3720
  96.       TabIndex        =   8
  97.       Top             =   240
  98.       Width           =   975
  99.    End
  100.    Begin Label Label8 
  101.       Alignment       =   2  'Center
  102.       BackColor       =   &H00C0C0C0&
  103.       BorderStyle     =   1  'Fixed Single
  104.       Caption         =   "MarkUp"
  105.       Height          =   255
  106.       Left            =   2760
  107.       TabIndex        =   7
  108.       Top             =   240
  109.       Width           =   975
  110.    End
  111.    Begin Label Label7 
  112.       Alignment       =   2  'Center
  113.       BackColor       =   &H00C0C0C0&
  114.       BorderStyle     =   1  'Fixed Single
  115.       Caption         =   "Cost"
  116.       Height          =   255
  117.       Left            =   1800
  118.       TabIndex        =   6
  119.       Top             =   240
  120.       Width           =   975
  121.    End
  122.    Begin Label Label6 
  123.       BackColor       =   &H00C0C0C0&
  124.       BorderStyle     =   1  'Fixed Single
  125.       Caption         =   "Product Name"
  126.       Height          =   255
  127.       Left            =   360
  128.       TabIndex        =   5
  129.       Top             =   240
  130.       Width           =   1455
  131.    End
  132. '---------------------------------------------------------
  133. ' This is the routine that creates the Captions for each
  134. ' Label Control. The captions consist of two strings for
  135. ' each line of the Label Control. The first string is the
  136. ' value that is to be displayed on a Label line. The second
  137. ' string is the End Of Line string (EOL$) which consists
  138. ' of several blank spaces to center the text in the
  139. ' middle of the label followed by a Carriage Return
  140. ' Chr$(13) and a LineFeed Chr$(10).
  141. ' This routine is called by the Form_Load routine and the
  142. ' VScroll1_Change routine.
  143. '---------------------------------------------------------
  144. Sub DisplayItems ()
  145.     '==> The End Of Line string.
  146.     EOL$ = "    " + Chr$(13) + Chr$(10)
  147.     '==> VScroll1.Value is the index to the Item that
  148.     '    is displayed as the first item in the table.
  149.     Ndx% = VScroll1.Value
  150.     '==> Build the strings for the first Item in the table.
  151.     Label1.Caption = Item(Ndx%).ProdName
  152.     Label2.Caption = Format$(Item(Ndx%).Cost, "0.00")
  153.     Label3.Caption = Format$(Item(Ndx%).MarkUp, "0.0000")
  154.     Label4.Caption = Format$(Item(Ndx%).Price, "0.00")
  155.     Label5.Caption = Format$(Item(Ndx%).InStock, "##,##0")
  156.     '==> Add the rest of the Items in the table to the
  157.     '    initial strings.
  158.     For I% = Ndx% + 1 To Ndx% + TableLen - 1
  159.         Label1.Caption = Label1.Caption + EOL$ + Item(I%).ProdName
  160.         Label2.Caption = Label2.Caption + EOL$ + Format$(Item(I%).Cost, "0.00")
  161.         Label3.Caption = Label3.Caption + EOL$ + Format$(Item(I%).MarkUp, "0.0000")
  162.         Label4.Caption = Label4.Caption + EOL$ + Format$(Item(I%).Price, "0.00")
  163.         Label5.Caption = Label5.Caption + EOL$ + Format$(Item(I%).InStock, "##,##0")
  164.     Next I%
  165.     '==> Append blanks to the last Item to keep it aligned.
  166.     Label2.Caption = Label2.Caption + "    "
  167.     Label3.Caption = Label3.Caption + "    "
  168.     Label4.Caption = Label4.Caption + "    "
  169.     Label5.Caption = Label5.Caption + "    "
  170. End Sub
  171. Sub Form_Load ()
  172.     '==> Set the random number generator seed.
  173.     Randomize
  174.     '==> Generate random sample data.
  175.     For I% = 1 To MaxItems
  176.         Item(I%).ProdName = String$(6, 33 + I%) '=> Dummy Product name.
  177.         Item(I%).Cost = Int(Rnd * 70 + 1)       '=> Cost of $1 to $70.
  178.         Item(I%).MarkUp = Rnd                   '=> Markup as decimal.
  179.         Item(I%).Price = Item(I%).Cost * (1 + Item(I%).MarkUp)
  180.         Item(I%).InStock = Rnd * 1500
  181.     Next I%
  182.     '==> Set the parameters for the vertical scroll bar.
  183.     VScroll1.Min = 1
  184.     VScroll1.Max = MaxItems - TableLen   '=> So we don't overrun the end of the Item array.
  185.     VScroll1.SmallChange = 1
  186.     VScroll1.LargeChange = TableLen - 1  '=> We want a 1 item overlap between pages.
  187.     VScroll1.Value = VScroll1.Min
  188.     '==> Display the Items. Note that the top
  189.     '    item in the table is always Item(VScroll1.Value).
  190.     Call DisplayItems
  191. End Sub
  192. Sub VScroll1_Change ()
  193.     '==> Display the set of Items beginning with the
  194.     '    current VScroll1.Value.
  195.     Call DisplayItems
  196. End Sub
  197.